<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>

<head>

<jsp:include page="/commonPages/admin-meta.jsp" flush="true" />
<!-- CSS files -->
<jsp:include page="/commonPages/admin-style.jsp" flush="true" />
<meta charset="UTF-8">
<title>修改密码的验证</title>
</head>

<body>
	<div id="wrapper">

		<!-- Navigation -->
		<jsp:include page="/commonPages/admin-navigator.jsp" flush="true" />

		<!-- Page Content -->
		<div id="page-wrapper">

			<div class="row">
				<div class="col-lg-12">
					<h1 class="page-header">修改密码</h1>
				</div>
			</div>









			<b id="passModifyMess" style="color: red;"></b>
			<form  onsubmit="return load()" id ="chagePassword">
				  
				
				<div class="userTd">
					<div class="dataTable_wrapper">
						<table class="table table-striped table-bordered table-hover"
							id="list_api">
							<input type = "hidden" name = "userId"  id = "userId" value = "${ sessionScope.session_user.id}"/ >
							<input type = "hidden" name = "userPass"  id = "userPass" value = "${ sessionScope.session_user.password}"/ >
							<tr>
								<td>旧密码：</td>
								<td><input type="password" id="oldpass" /></td>
							</tr>
							
							<tr>
								<td>新密码：</td>
								<td><input type="password" id="newpass" name = "newPassword"/></td>
							</tr>
							<tr>
								<td>确认密码：</td>
								<td><input type="password" id="confirmpass" name = "newPassword"/></td>
							</tr>
							
							<tr>
								<td colspan="2" align="center">
								<input type="submit" id="sub-submit" value="提交" /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input
									type="reset" id="reset" value="重置" /></td>
							</tr>


						</table>
					</div>
					<!-- /.table-responsive -->

				</div>



			</form>


		</div>
	</div>
	<jsp:include page="/commonPages/admin-script.jsp" flush="true" />

	<!-- Page-Level Demo Scripts - Tables - Use for reference -->
</body>
<script>
	
	 function load(){
		 
			var inp = $('#changePassword');
			var oldPass =  document.getElementById("oldpass").value;
			var newPassword = document.getElementById("newpass").value;
			var confirmpass = document.getElementById("confirmpass").value;
			var userId = document.getElementById("userId").value;
			var userPass = document.getElementById("userPass").value;
			
			if(oldPass!= userPass ){
				alert("原密码不对");
			}
			if(newPassword!= confirmpass ){
				alert("两次输入密码不一致");
			}
			
			$("#sub-submit").button('loading');
			$.ajax({
				type:"POST",
				url:"user/updataPassword",
				data:{
					userId : userId,
					newPassword : newPassword,
					
					
				},
				error:function(a,b,c){
					alert('服务器请求失败');
					$("#sub-submit").button('reset');
				},
				success:function(data){
					if(data == "success"){
						//if success
					   window.location.href = jsBasePath+"userInfo.jsp"
					
					}
					else{
						$("#sub-submit").button('reset');
						alert(data);
					}
				}
			});
			return false;
		  }
</script>
</body>

</html>